home *** CD-ROM | disk | FTP | other *** search
- import java.applet.Applet;
- import java.awt.Color;
- import java.awt.Component;
- import java.awt.Dimension;
- import java.awt.Event;
- import java.awt.Font;
- import java.awt.FontMetrics;
- import java.awt.Graphics;
- import java.awt.Image;
- import java.io.DataInputStream;
- import java.io.InputStream;
-
- public class ScrollTextVert extends Applet implements Runnable {
- Thread scrollThread;
- int bannerHeight = 20;
- int maxWidth;
- int maxHeight;
- public String message;
- int messageX = 5;
- int messageY = 5;
- int messageW;
- // $FF: renamed from: X int
- int field_0;
- // $FF: renamed from: Y int
- int field_1 = 2;
- int scrollUnit = 1;
- int sleepTime;
- public Dimension lastS;
- public Font messageF;
- Image textImage;
- Graphics textGC;
- static boolean loaded;
- // $FF: renamed from: f java.io.InputStream
- InputStream field_2;
- // $FF: renamed from: df java.io.DataInputStream
- DataInputStream field_3;
- Image bannerImage;
- Graphics bannerGraphic;
- boolean flag = true;
- int color;
- int bkcolor = 3;
- Color backgroundColor;
- Color textColor;
- Color lineColor;
- int fontH;
- int fontName;
- int fontL;
- String strLine;
- String curFont;
- boolean load_flag;
- int load_count;
- Font curTTF;
- int vertScrollIndex;
- boolean vertScrollFlag;
- int fastScrollIndex;
- boolean fastScrollFlag;
- boolean needFastScroll;
- int horScrollIndex;
- String horScrollStr;
- boolean horScrollFlag;
- boolean horF;
- int lineSleepTime;
- int charSleepTime;
- int pageSleepTime;
- boolean onlineFlag;
- boolean offlineFlag;
-
- public void init() {
- Dimension var1 = ((Component)this).size();
- this.maxWidth = var1.width - 4;
- this.maxHeight = var1.height;
- this.bannerImage = ((Component)this).createImage(this.maxWidth, this.maxHeight);
- this.bannerGraphic = this.bannerImage.getGraphics();
- this.textImage = ((Component)this).createImage(this.maxWidth, this.maxHeight);
- this.textGC = this.textImage.getGraphics();
- this.lastS = new Dimension(1, 1);
- ((Component)this).setBackground(Color.white);
- this.message = "123";
- this.createBannerParams();
- ((Component)this).repaint();
- }
-
- public void start() {
- if (this.scrollThread == null) {
- this.scrollThread = new Thread(this);
- this.scrollThread.start();
- loaded = true;
- this.offlineFlag = true;
- }
-
- ((Applet)this).showStatus(this.getAppletInfo());
- }
-
- public void stop() {
- if (this.scrollThread != null && this.scrollThread.isAlive()) {
- this.scrollThread.stop();
- }
-
- loaded = false;
- this.onlineFlag = true;
- ((Component)this).repaint();
- this.scrollThread = null;
- }
-
- public void run() {
- Thread var1 = Thread.currentThread();
- var1.setPriority(1);
- ((Component)this).repaint();
-
- while(this.scrollThread == var1) {
- while(loaded) {
- this.nextPos();
-
- try {
- Thread.sleep((long)this.sleepTime);
- } catch (InterruptedException var2) {
- }
- }
- }
-
- }
-
- public synchronized String readText() {
- String var1 = null;
- if (!this.load_flag) {
- try {
- var1 = ((Applet)this).getParameter("Font" + this.load_count);
- } catch (Exception var7) {
- }
-
- if (var1 != null) {
- this.curFont = var1;
- }
-
- try {
- var1 = ((Applet)this).getParameter("Layout" + this.load_count);
- } catch (Exception var6) {
- }
-
- if (var1 != null) {
- this.fontL = Integer.parseInt(var1);
- }
-
- try {
- var1 = ((Applet)this).getParameter("FHeight" + this.load_count);
- } catch (Exception var5) {
- }
-
- if (var1 != null) {
- this.fontH = Integer.parseInt(var1);
- }
-
- this.curTTF = new Font(this.curFont, this.fontL, this.fontH);
-
- try {
- var1 = ((Applet)this).getParameter("backgroundcolor" + this.load_count);
- } catch (Exception var4) {
- }
-
- if (var1 != null) {
- this.backgroundColor = this.decodeColor(var1);
- }
-
- try {
- var1 = ((Applet)this).getParameter("color" + this.load_count);
- } catch (Exception var3) {
- }
-
- if (var1 != null) {
- this.textColor = this.decodeColor(var1);
- }
-
- try {
- var1 = ((Applet)this).getParameter("Text" + this.load_count);
- ++this.load_count;
- } catch (Exception var2) {
- }
-
- if (var1 == null) {
- this.load_flag = true;
- this.load_count = 0;
- }
- }
-
- if (this.load_flag) {
- var1 = " ";
- }
-
- return var1;
- }
-
- synchronized Color decodeColor(String var1) {
- int var2 = 0;
-
- try {
- if (var1.startsWith("0x")) {
- var2 = Integer.parseInt(var1.substring(2), 16);
- } else if (var1.startsWith("#")) {
- var2 = Integer.parseInt(var1.substring(1), 16);
- } else if (var1.startsWith("0") && var1.length() > 1) {
- var2 = Integer.parseInt(var1.substring(1), 8);
- } else {
- var2 = Integer.parseInt(var1, 10);
- }
-
- return new Color(var2);
- } catch (NumberFormatException var3) {
- return null;
- }
- }
-
- public synchronized void paint(Graphics var1) {
- }
-
- public synchronized void update(Graphics var1) {
- if (this.onlineFlag) {
- var1.setColor(this.lineColor);
- var1.drawRect(0, 0, this.maxWidth, this.maxHeight - 2);
- this.onlineFlag = false;
- }
-
- if (this.offlineFlag) {
- var1.setColor(this.backgroundColor);
- var1.drawRect(0, 0, this.maxWidth, this.maxHeight - 2);
- this.offlineFlag = false;
- }
-
- if (loaded) {
- if (!this.needFastScroll) {
- if (!this.vertScrollFlag && !this.horScrollFlag) {
- var1.setColor(this.backgroundColor);
- this.textGC.setColor(this.backgroundColor);
- this.textGC.fillRect(0, 0, this.maxWidth, this.maxHeight);
- var1.fillRect(0, 0, this.maxWidth, this.maxHeight);
- var1.setColor(this.textColor);
- this.textGC.setColor(this.textColor);
- this.load_flag = false;
- } else {
- this.drawText(var1);
- }
- } else {
- var1.clipRect(5, 5, this.maxWidth - 5, this.maxHeight - 5);
- var1.drawImage(this.textImage, 0, this.fastScrollIndex, this);
-
- try {
- Thread.sleep((long)(this.lineSleepTime + this.fastScrollIndex / (int)((double)this.maxHeight + 0.1)));
- } catch (InterruptedException var2) {
- }
- }
- }
- }
-
- public synchronized void drawText(Graphics var1) {
- if (this.horF) {
- this.textGC.setColor(this.textColor);
- this.textGC.clipRect(5, 5, this.maxWidth - 10, this.maxHeight - 5);
- this.textGC.setFont(this.curTTF);
- this.textGC.drawString(this.horScrollStr, this.field_0 + this.messageX + 2, this.field_1 + this.messageY + 2 + this.vertScrollIndex * this.fontH);
- }
-
- var1.setColor(this.textColor);
- var1.clipRect(5, 5, this.maxWidth - 10, this.maxHeight - 5);
- var1.setFont(this.curTTF);
- var1.drawString(this.horScrollStr.substring(0, this.horScrollIndex), this.field_0 + this.messageX + 2, this.field_1 + this.messageY + 2 + this.vertScrollIndex * this.fontH);
-
- try {
- Thread.sleep((long)this.charSleepTime);
- } catch (InterruptedException var2) {
- }
- }
-
- public synchronized void nextPos() {
- if (this.horScrollFlag) {
- if (this.horScrollIndex < this.horScrollStr.length()) {
- ++this.horScrollIndex;
- this.horScrollFlag = true;
- this.horF = false;
- } else {
- this.horScrollFlag = false;
- this.vertScrollFlag = true;
- this.horScrollIndex = 0;
- this.horF = true;
- }
- } else if (!this.needFastScroll) {
- if (this.vertScrollIndex < (this.maxHeight - 10 - this.fontH) / this.fontH && this.flag) {
- this.horScrollStr = this.readText();
- ++this.vertScrollIndex;
- this.vertScrollFlag = false;
- this.horScrollFlag = true;
- } else {
- this.vertScrollFlag = false;
- this.vertScrollIndex = -1;
- this.needFastScroll = true;
-
- try {
- Thread.sleep((long)this.pageSleepTime);
- } catch (InterruptedException var1) {
- }
- }
- } else if (this.fastScrollIndex > -this.maxHeight) {
- --this.fastScrollIndex;
- this.fastScrollFlag = true;
- } else {
- this.fastScrollFlag = false;
- this.fastScrollIndex = 0;
- this.needFastScroll = false;
- }
-
- ((Component)this).repaint();
- }
-
- public void createBannerParams() {
- String var1 = "";
- this.lastS.width = 300;
- this.lastS.height = 20;
-
- try {
- var1 = ((Applet)this).getParameter("lineColor");
- } catch (Exception var15) {
- }
-
- if (var1 != null) {
- this.lineColor = this.decodeColor(var1);
- }
-
- try {
- var1 = ((Applet)this).getParameter("color");
- } catch (Exception var14) {
- }
-
- if (var1 != null) {
- this.textColor = this.decodeColor(var1);
- }
-
- try {
- var1 = ((Applet)this).getParameter("backgroundcolor");
- } catch (Exception var13) {
- }
-
- if (var1 != null) {
- this.backgroundColor = this.decodeColor(var1);
- }
-
- try {
- var1 = ((Applet)this).getParameter("Font");
- } catch (Exception var12) {
- }
-
- if (var1 != null) {
- this.curFont = var1;
- }
-
- try {
- var1 = ((Applet)this).getParameter("Layout");
- } catch (Exception var11) {
- }
-
- if (var1 != null) {
- this.fontL = Integer.parseInt(var1);
- }
-
- try {
- var1 = ((Applet)this).getParameter("FHeight");
- } catch (Exception var10) {
- }
-
- if (var1 != null) {
- this.fontH = Integer.parseInt(var1);
- }
-
- try {
- var1 = ((Applet)this).getParameter("charSleepTime");
- } catch (Exception var9) {
- }
-
- if (var1 != null) {
- this.charSleepTime = Integer.parseInt(var1);
- }
-
- try {
- var1 = ((Applet)this).getParameter("lineSleepTime");
- } catch (Exception var8) {
- }
-
- if (var1 != null) {
- this.lineSleepTime = Integer.parseInt(var1);
- }
-
- try {
- var1 = ((Applet)this).getParameter("pageSleepTime");
- } catch (Exception var7) {
- }
-
- if (var1 != null) {
- this.pageSleepTime = Integer.parseInt(var1);
- }
-
- int var2 = this.fontH;
- Font var3 = new Font(this.curFont, this.fontL, this.fontH);
- this.curTTF = var3;
- ((Component)this).setFont(var3);
- FontMetrics var4 = ((Component)this).getFontMetrics(var3);
- int var5 = var4.getHeight();
- var5 = var2 * 18 / var5;
- this.messageF = new Font("TimesRoman", 0, var5);
- FontMetrics var6 = ((Component)this).getFontMetrics(this.messageF);
- var5 = var6.getHeight();
- this.messageY = (20 - var5 >> 1) + var6.getAscent();
- }
-
- public String getAppletInfo() {
- return "Text Scroller v. 0.1 by Alex Vlasenko, 1997";
- }
-
- public boolean handleEvent(Event var1) {
- switch (var1.id) {
- case 504:
- ((Applet)this).showStatus(this.getAppletInfo());
- this.stop();
- return true;
- case 505:
- this.start();
- ((Applet)this).showStatus(" ");
- return true;
- default:
- return true;
- }
- }
-
- public ScrollTextVert() {
- this.backgroundColor = Color.white;
- this.textColor = Color.black;
- this.lineColor = Color.red;
- this.fontH = 14;
- this.fontName = 1;
- this.strLine = "";
- this.curFont = "TimesRoman";
- this.load_flag = false;
- this.vertScrollIndex = -1;
- this.vertScrollFlag = false;
- this.fastScrollFlag = false;
- this.needFastScroll = false;
- this.horScrollStr = "";
- this.horScrollFlag = false;
- this.horF = false;
- this.lineSleepTime = 4;
- this.charSleepTime = 15;
- this.pageSleepTime = 500;
- this.onlineFlag = false;
- this.offlineFlag = false;
- }
- }
-